package com.bos.dao.impl;

import com.bos.dao.StatusLaporanDAO;
import com.bos.domain.Anggaran;
import com.bos.domain.Periode;
import com.bos.domain.Sekolah;
import com.bos.domain.StatusLaporan;
import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by IntelliJ IDEA.
 * User: Latief
 * Date: 3/15/11
 * Time: 9:39 PM
 * To change this template use File | Settings | File Templates.
 */
@Repository
public class StatusLaporanDAOImpl extends GenericDAOImpl<StatusLaporan> implements StatusLaporanDAO {

    public StatusLaporanDAOImpl(){
        super(StatusLaporan.class);
    }

    public List<StatusLaporan> getBySekolah(Sekolah sekolah) throws DataAccessException {
           return entityManager.createQuery("select o from " + type.getName() + " o where o.sekolah = :sekolah")
                   .setParameter("sekolah", sekolah)
                   .getResultList();
       }

    public StatusLaporan getBySekolahPeriode(Sekolah sekolah, Periode periode) throws DataAccessException {
        return (StatusLaporan) entityManager.createQuery("SELECT o FROM " + type.getName() + " o WHERE o.sekolah = :sekolah AND o.periode = :periode")
                .setParameter("sekolah", sekolah)
                .setParameter("periode", periode)
                .getSingleResult();
    }
}
